package com.xiaoyg.controller;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author xiaoyg
 * @Title: IndexController
 * @ProjectName ModuleProject
 * @Description: 首页控制器
 * @date 2018/8/2911:17
 */
@Controller
@RequestMapping("/")
public class IndexController {

    Logger logger = LoggerFactory.getLogger(IndexController.class);

    @RequestMapping(value = "/{name}", method = {RequestMethod.GET})
    public String getMoview(@PathVariable String name, ModelMap modelMap) {
        modelMap.addAttribute("name", name);
        modelMap.addAttribute("query", "");
        modelMap.addAttribute("subit", "");
        return "index";
    }

    @RequestMapping(value = "/query", method = {RequestMethod.GET})
    public String query(@RequestParam("name") String name, ModelMap modelMap) {
        modelMap.addAttribute("name", "");
        modelMap.addAttribute("query", name);
        modelMap.addAttribute("subit", "");
        return "index";
    }

    @RequestMapping(value = "/submit", method = {RequestMethod.GET})
    public String submit(@RequestParam("name") String name, ModelMap modelMap) {
        modelMap.addAttribute("name", "");
        modelMap.addAttribute("query", "");
        modelMap.addAttribute("subit", name);
        return "index";
    }

    @RequestMapping(value = "/", method = {RequestMethod.GET})
    public String xiaoyg() {
        logger.info("visit xiaoyg interface!");
        return "index";
    }
}

